Binary in Computing and the Web I
Numbers
Decimal Numbers
The decimal number system, in use throughout the world (there are exceptions), has ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. We probably use the decimal system because we have 10 fingers, although when we count on our fingers, we usually start with 1, not 0. In fact, the inclusion of a 0 in the number system is thought to have been a particularly insighful advance in counting. For example, the number for ten is 10, meaning tens and 0 ones. Without the concept of zero, we would need to have a different symbol for 10 or some other combination (think of Roman numerals). Having a zero in our numbering system also simplifies arithmetic tremendously.
When we start with 0 and begin counting in decimal we utilize all ten of the decimal digits when we get to 9. To represent the tenth item we are counting, we use 10. That is, as already noted, the 1 is in the "tens column" and the 0 is in the "ones column," representing that we have found 1 tens and 0 ones. We then continue counting with 11 (1 tens and 1 ones). We eventually get to, say, 58, which represents 5 tens and 8 ones. Going further we might get to 5,342. This represents 5 thousands, 3 hundreds, 4 tens, and 2 ones.
Binary Numbers
The binary number system has, in contrast to the decimal system, just two digits: 0 and 1. Thus all numbers must be represented with just these two digits.
We count in binary just as we do in decimal, but using two digits instead. We start with 0 and count until we run out of digits, which in this case isn't far: 0, 1. What do we do when we reach 1? Since we have run out of digits we move from 1 to 10. Meaning we have found 1 twos and 0 ones. Thus, counting proceeds this way:
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, ...
In fashion analogous to counting in decimal, where each position in a number represents a power of ten (the ones position, the tens position, the hundreds position, the thousands position, and so on), in binary each position in a number represents a power of 2 (the ones position, the twos position, the fours position, the eights position, the sixteens position, and so on). So, the binary number
100011
represents (starting from the right) 1 ones, 1 twos, 0 fours, 0 eights, 0 sixteens, and 1 thirty-twos. In decimal this is 1 + 2 + 32, which is 35.
A single binary digit is called a bit. So the binary number system is just a two-bit counting system, the bits being 0 and 1.
Hexadecimal Numbers
The hexadecimal number system has 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
By convention, for hexadecimal digits we borrow the ten digits we already have from our familiar decimal number system and then use A, B, C, D, E, and F from our alphabet to get to 16 digits. So counting in hexadecimal proceeds as
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13, 14, 15, 16, 17, 18. 19. 1A, 1B, 1C, 1D, 1E, 1F, 100, ...
There is only one use for hexadecimal numbers in our context of computing: to represent binary strings in a more compact form for human consumption. One hexadecimal digit can stand for exactly four binary bits. Since binary strings can be very long, it is easier to view each four bits of such a string as hexadecimal digits. The correlation of four bit chunks to hexadecimal digits is:
0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
0 1 2 3 4 5 6 7 8 9 A B C D E F
Now consider representing a long bit string in hexadecimal form. Here is an example
1001101110001111010010
We break this string into four-bit chunks starting from the right side. If this does not leave a final four-bit chunk on the left side we add leading zeros to that leftmost chunk. We then write the corresponding hexadecimal digit below each four-bit chunk
0010 0110 1110 0011 1101 0010
2 6 E 3 D 2
Thus, the hexadecimal equivalent of the binary string is 26E3D2, or 26e3d2, which is much easier to write down than the binary string it represents. Normally, if a binary string must be represented in a Web page or elsewhere for, say, the encoding of a particular color, the hexadecimal version of the code will be shown, not the binary version.
So What's the Purpose?
What is the purpose of binary numbers in computing and the Web? Computers are designed with binary devices, devices that can be in exactly one of two different states, which might be represented as electrical voltages, polarized spots (in either one of two different polarities) on the magnetic surface of a hard drive platter, spots burned by a laser into a CD or DVD (there is a burned spot or there isn't), and so forth. It just turned out that building two-state devices was the easiest and best way to go as digital computers were invented and improved. So, all numbers for used in arithmetic computations in a computer as well as all codes that represent digital music, images, videos, colors, all of the characters in the various languages of the world, and so forth are binary-based.
But Why Do We Need to Know Such Technical Stuff?
It would be great if this dependence on binary were transparent, that is, that we didn't need to be aware of it. However, references to binary show up all of the time. The speed of your connection to the internet is advertised in "bits per second." HTML codes for colors that appear on the web are represented in binary. The list goes on. If we aren't binary aware, we are less informed and thus less able to make decisions and judgments about the digital world we interact with.
Links to Other Resources
Here are links that give you more review of binary and hexadecimal numbers. You can surely find more through a Web search.
Binary Numbers
Hexadecimal Numbers
Hexadecimal is only for human consumption. Each four bits of a binary sequence of bits, starting from the least significant end of the string, can be represented by a single hexadecimal digit.
Conversions Among Number Bases